#include <cstdio>
#include <algorithm>

using namespace std;

int n, m, f[ 10001 ];
int mabs( int x ) { return ( x < 0 )?-x :x; }

struct Node
{
    int x, y, t;
};

bool operator < ( const Node &a, const Node &b )
{
    return a.t < b.t;
}

Node a[ 10001 ];

void init( )
{
    int i;
    for ( i = 0; i < m; i++ )
        scanf("%d%d%d", &a[ i ].t, &a[ i ].x, &a[ i ].y);
    sort( a, a + m );
}

void work( )
{
    int i, j, maxn = 1;
    for ( i = 0; i < m; i++ )
    {
        f[ i ] = 1;
        for ( j = 0; j < i; j++ )
            if ( mabs( a[ i ].x - a[ j ].x ) + mabs( a[ i ].y - a[ j ].y ) <= a[ i ].t - a[ j ].t && f[ i ] < f[ j ] + 1 )
                f[ i ] = f[ j ] + 1;
        if ( maxn < f[ i ] )
            maxn = f[ i ];
    }
    printf("%d\n", maxn);
}

int main( )
{
    while ( scanf("%d%d", &n, &m) != EOF )
    {
        if ( n == 0 && m == 0 )
            break;
        init( );
        work( );
    }
    return 0;
}
